/*
 * ControlPanel.java
 *
 * Created on 1 de septiembre de 2008, 22:58
 */

package r4p_gui;

import java.util.ArrayList;

/**
 *
 * @author  nemesis
 */
public class ControlPanel extends javax.swing.JPanel {

    boolean[] buttonStatus;
    
    /** Creates new form ControlPanel */
    public ControlPanel() {
        initComponents();
	buttonStatus = new boolean[6];
	for (int i = 0; i < buttonStatus.length; i++) {
	    buttonStatus[i] = false;
	}
    }
    
    public void relanguage(String emergencyStop, String send, String init2base, String biped, String demo1, String demo2, String demo3) {
	this.buttonSendCommand.setText(send);
	this.buttonFunction_1.setText(emergencyStop);
	this.buttonFunction_0.setText(init2base);
	this.buttonFunction_2.setText(biped);
	this.buttonFunction_3.setText(demo1);
	this.buttonFunction_4.setText(demo2);
	this.buttonFunction_5.setText(demo3);
    }
    
    public void relanguage(ArrayList<String> controls) {
	this.buttonSendCommand.setText(controls.get(1));
	this.buttonFunction_1.setText(controls.get(0));
	this.buttonFunction_0.setText(controls.get(2));
	this.buttonFunction_2.setText(controls.get(3));
	this.buttonFunction_3.setText(controls.get(4));
	this.buttonFunction_4.setText(controls.get(5));
	this.buttonFunction_5.setText(controls.get(6));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonLeft = new javax.swing.JButton();
        buttonForward = new javax.swing.JButton();
        buttonRight = new javax.swing.JButton();
        buttonBackward = new javax.swing.JButton();
        buttonSendCommand = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        buttonFunction_0 = new javax.swing.JButton();
        buttonFunction_1 = new javax.swing.JButton();
        buttonFunction_2 = new javax.swing.JButton();
        buttonFunction_3 = new javax.swing.JButton();
        buttonFunction_4 = new javax.swing.JButton();
        buttonFunction_5 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        textCommand = new javax.swing.JTextPane();
        jLabel1 = new javax.swing.JLabel();

        setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Remote Controls", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("DejaVu Sans", 0, 10))); // NOI18N

        buttonLeft.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/back.png")); // NOI18N
        buttonLeft.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonLeftMouseClicked(evt);
            }
        });

        buttonForward.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/go-up.png")); // NOI18N
        buttonForward.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonForwardMouseClicked(evt);
            }
        });

        buttonRight.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/forward.png")); // NOI18N
        buttonRight.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonRightMouseClicked(evt);
            }
        });

        buttonBackward.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/down.png")); // NOI18N
        buttonBackward.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonBackwardMouseClicked(evt);
            }
        });

        buttonSendCommand.setText("send");
        buttonSendCommand.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonSendCommandMouseClicked(evt);
            }
        });

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        buttonFunction_0.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/init-base.png")); // NOI18N
        buttonFunction_0.setText("Init to base position");
        buttonFunction_0.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_0.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_0MouseClicked(evt);
            }
        });

        buttonFunction_1.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/emergency-stop.png")); // NOI18N
        buttonFunction_1.setText("Emergency STOP!");
        buttonFunction_1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_1MouseClicked(evt);
            }
        });

        buttonFunction_2.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/base-2patas.png")); // NOI18N
        buttonFunction_2.setText("Biped Position");
        buttonFunction_2.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_2MouseClicked(evt);
            }
        });

        buttonFunction_3.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/demo-icon.png")); // NOI18N
        buttonFunction_3.setText("Demo 1");
        buttonFunction_3.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_3MouseClicked(evt);
            }
        });

        buttonFunction_4.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/demo-icon.png")); // NOI18N
        buttonFunction_4.setText("Demo 2");
        buttonFunction_4.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_4MouseClicked(evt);
            }
        });

        buttonFunction_5.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/demo-icon.png")); // NOI18N
        buttonFunction_5.setText("Demo 3");
        buttonFunction_5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        buttonFunction_5.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                buttonFunction_5MouseClicked(evt);
            }
        });

        jScrollPane1.setViewportView(textCommand);

        jLabel1.setFont(new java.awt.Font("DejaVu Sans", 0, 12)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Robot Current State");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(buttonForward)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(buttonLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(buttonBackward)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 9, Short.MAX_VALUE)
                        .addComponent(buttonRight))
                    .addComponent(buttonFunction_1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(buttonSendCommand, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 195, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 5, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(buttonFunction_2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                    .addComponent(buttonFunction_0, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                    .addComponent(buttonFunction_5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                    .addComponent(buttonFunction_4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE)
                    .addComponent(buttonFunction_3, javax.swing.GroupLayout.DEFAULT_SIZE, 164, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(buttonFunction_0)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFunction_2)
                .addGap(18, 18, 18)
                .addComponent(buttonFunction_3, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFunction_4, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFunction_5, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonForward)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(buttonLeft)
                    .addComponent(buttonBackward)
                    .addComponent(buttonRight))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonFunction_1)
                .addGap(18, 18, 18)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonSendCommand))
        );
    }// </editor-fold>//GEN-END:initComponents

private void buttonFunction_0MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_0MouseClicked
    //init to base button:
    if (this.buttonStatus[0]) {
	this.buttonFunction_0.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/init-base.png"));
	this.buttonStatus[0] = false;
    } else {
	this.buttonFunction_0.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/base-init.png"));
	this.buttonStatus[0] = true;
    }
}//GEN-LAST:event_buttonFunction_0MouseClicked

private void buttonFunction_1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_1MouseClicked
    //emergency stop button:
    if (this.buttonStatus[1]) {
	this.buttonFunction_1.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/continue.png"));
	this.buttonStatus[1] = false;
    } else {
	this.buttonFunction_1.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/emergency-stop.png"));
	this.buttonStatus[1] = true;
    }
}//GEN-LAST:event_buttonFunction_1MouseClicked

private void buttonFunction_2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_2MouseClicked
    //biped position button:
    if (this.buttonStatus[2]) {
	this.buttonFunction_2.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/2patas-base.png"));
	this.buttonStatus[2] = false;
    } else {
	this.buttonFunction_2.setIcon(new javax.swing.ImageIcon("/home/nemesis/NetBeansProjects/R4P_gui/icons/base-2patas.png"));
	this.buttonStatus[2] = true;
    }
}//GEN-LAST:event_buttonFunction_2MouseClicked

private void buttonFunction_3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_3MouseClicked
    //demo 1 button:
}//GEN-LAST:event_buttonFunction_3MouseClicked

private void buttonFunction_4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_4MouseClicked
    //demo 2 button:
}//GEN-LAST:event_buttonFunction_4MouseClicked

private void buttonFunction_5MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonFunction_5MouseClicked
    //demo 3 button:
}//GEN-LAST:event_buttonFunction_5MouseClicked

private void buttonForwardMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonForwardMouseClicked
    //forward button:
    
}//GEN-LAST:event_buttonForwardMouseClicked

private void buttonLeftMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonLeftMouseClicked
    //left button:
}//GEN-LAST:event_buttonLeftMouseClicked

private void buttonBackwardMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonBackwardMouseClicked
    //backward button:
}//GEN-LAST:event_buttonBackwardMouseClicked

private void buttonRightMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonRightMouseClicked
    //right button:
}//GEN-LAST:event_buttonRightMouseClicked

private void buttonSendCommandMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonSendCommandMouseClicked
    //send button:
}//GEN-LAST:event_buttonSendCommandMouseClicked


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonBackward;
    private javax.swing.JButton buttonForward;
    private javax.swing.JButton buttonFunction_0;
    private javax.swing.JButton buttonFunction_1;
    private javax.swing.JButton buttonFunction_2;
    private javax.swing.JButton buttonFunction_3;
    private javax.swing.JButton buttonFunction_4;
    private javax.swing.JButton buttonFunction_5;
    private javax.swing.JButton buttonLeft;
    private javax.swing.JButton buttonRight;
    private javax.swing.JButton buttonSendCommand;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTextPane textCommand;
    // End of variables declaration//GEN-END:variables

}
